<template>
  <div>
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="用户名">
        <el-input v-model="formInline.user" placeholder="用户名"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit()">查询</el-button>
      </el-form-item>
    </el-form>

    <el-table :data="list" style="width: 100%">
      <el-table-column
        prop="messageId"
        label="ID"
        width="100"
      ></el-table-column>
      <el-table-column
        prop="messageTittle"
        label="标题"
        width="100"
      ></el-table-column>
      <el-table-column
        prop="messageInfo"
        label="内容"
        width="300"
      ></el-table-column>
      <el-table-column
        prop="messageSender"
        label="发送人"
        width="100"
      ></el-table-column>
      <el-table-column
        prop="messageReceiver"
        label="接收人"
        width="100"
      ></el-table-column>
      <el-table-column
        prop="messageRead"
        label="已读数"
        width="100"
      ></el-table-column>
      <el-table-column
        prop="messageJieshou"
        label="接收人数"
        width="100"
      ></el-table-column>
      <el-table-column prop="messageCreateTime" label="创建时间" width="200">
        <!-- <template>{{ currentTime }}</template> -->
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="1"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="limit"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
  </div>
</template>

<script>
import { chaxun, getlink } from "@/apis/lihan/Index.js";
export default {
  data() {
    return {
      messageCreateTime: "",
      page: 1,
      limit: 5,
      total: 10,
      formInline: {
        user: "",
        region: "",
      },
      list: [],
      currentPage1: 1,
    };
  },
  mounted() {
    this.link();
  },
  methods: {
    link() {
      chaxun(this.page, this.limit).then((ok) => {
        this.list = ok.data.data.records;
        this.page = ok.data.data.pages;
        this.limit = ok.data.data.size;
        this.total = ok.data.data.total;
      });
    },

    onSubmit() {
      if (this.formInline.value != "") {
        getlink(this.formInline.user).then((ok) => {
          console.log(ok);
          this.list = ok.data.data;
          this.page = ok.data.data.pages;
          this.limit = ok.data.data.size;
          this.total = ok.data.data.total;
        });
      }
    },

    handleSizeChange(val) {
      (this.limit = val), this.link();
    },
    handleCurrentChange(val) {
      (this.page = val), this.link();
    },
  },
};
</script>

<style scoped>
</style>